package com.ayi.dao.bookdao;

import com.ayi.utils.CloseConn;
import com.ayi.utils.GetConn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


/**
 * @author Ayingzz
 * @create 2021/12/3 9:55
 */
public class DeleteBook {

    /**
     * 下架一本书
     * @param id
     * @return
     */
    public boolean deletedBookFromBooksById(int id) {
        Connection conn = new GetConn().getConnection();
        String sql = "delete from Books where id = ?";
        try {
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, id);
            ps.execute();
            return true;
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return false;
    }


}
